<template>
  <!-- 通知公告 -->
  <div class="card">
    <div class="card-top flex justify-between">
      <div class="flex">
        <div
          v-for="(item, index) in menuList"
          :key="index"
          class="card-top-menu"
          :class="activeMenuID === item.id ? 'card-top-menu-active' : ''"
          @click="handleClickTopMenu(item)"
        >
          {{ item.name }}
        </div>
      </div>
      <el-button type="primary" text="text" class="btn-more"
        >更多<van-icon name="arrow" class="ml-[5px]"
      /></el-button>
    </div>
    <el-divider />
    <div class="card-bottom">
      <div
        v-for="(item, index) in dataList"
        :key="index"
        class="flex justify-between mb-[20px]"
      >
        <div>
          <el-tag :type="item.type">{{ item.typeName }}</el-tag>
          <el-link href="" target="" class="ml-[10px]">{{
            item.title
          }}</el-link>
        </div>
        <div class="flex text-[14px] gray">
          <div class="truncate w-[140px]">发布部门：{{ item.dept }}</div>
          <div class="ml-[10px]">{{ item.date }}</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import { ref, reactive } from "vue";
import { useRouter } from "vue-router";
let activeMenuID = ref(1);
const menuList = reactive([
  { id: 1, name: "通知公告" },
  { id: 2, name: "综合新闻" },
  { id: 3, name: "学校公告" }
]);
const dataList = reactive([
  {
    type: "primary",
    typeName: "一般",
    title: "2025年下半年中小学教师资格考试笔试报名",
    dept: "教学科",
    date: "2025-06-28"
  },
  {
    type: "primary",
    typeName: "一般",
    title: "在校生4月19日普通话测试通知",
    dept: "教学科",
    date: "2025-04-15"
  },
  {
    type: "warning",
    typeName: "紧急",
    title: "测试1111-2",
    dept: "临时部门",
    date: "2024-11-11"
  },
  {
    type: "primary",
    typeName: "一般",
    title: "省市违规吃喝问题专项整治会议传达提纲",
    dept: "信息科",
    date: "2023-01-14"
  },
  {
    type: "primary",
    typeName: "一般",
    title: "关于机房服务器设备升级通知",
    dept: "科研处",
    date: "2021-05-28"
  },
  {
    type: "primary",
    typeName: "一般",
    title: "关于机房服务器设备升级通知",
    dept: "信息化数据管理处",
    date: "2021-05-28"
  },
  {
    type: "primary",
    typeName: "一般",
    title: "关于加强网络安全防护的通知",
    dept: "信息化数据管理处",
    date: "2021-05-28"
  }
]);
const handleClickTopMenu = item => {
  activeMenuID.value = item.id;
  router.push({ path: item.url });
};
</script>

<style lang="less" scoped>
.el-link {
  //   font-size: 16px;
  color: var(--color-main-text-secondary);
  &:hover {
    color: var(--el-color-primary);
  }
}
.gray {
  color: var(--color-main-text);
}
.btn-more {
  color: #73665b;
}
</style>
